package com.lam.framework.bean.service;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.lam.common.utils.JsonUtil;
import com.lam.common.utils.StringUtils;
import com.lam.framework.bean.entity.SysOperLog;
import com.lam.framework.bean.mapper.OperLogMapper;
import com.lam.framework.operLog.model.OperateLog;
import com.lam.framework.operLog.service.OperLogService;

/**
 * 操作日志记录Service业务层处理
 * 
 * @author admin
 * @date 2022-08-03
 */
@Service
public class OperLogServiceImpl implements OperLogService {


    @Autowired
    private OperLogMapper operLogMapper;
    
    @Override
    @Transactional
	public void saveLog(OperateLog operLog) {
    	SysOperLog sysOperLog = JsonUtil.toJavaObject(operLog, SysOperLog.class);
    	sysOperLog.setReqDesc(StringUtils.substring(sysOperLog.getReqDesc(), 0, 200));
    	sysOperLog.setReqParam(StringUtils.substring(sysOperLog.getReqParam(), 0, 4000));
    	sysOperLog.setOperParam(StringUtils.substring(sysOperLog.getOperParam(), 0, 4000));
    	sysOperLog.setResResult(StringUtils.substring(sysOperLog.getResResult(), 0, 2000));
    	operLogMapper.insert(sysOperLog);
	}

}
